package edu.gdkm.demo12;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class MapTest {
    public static void main(String[] args) {
        Map<String,String> hashMap = new HashMap<>();
        hashMap.put("001","北京");
        hashMap.put("002","上海");
        System.out.println(hashMap);
        System.out.println(hashMap.get("001"));
        hashMap.put("001","广州");
        System.out.println(hashMap);
        System.out.println(hashMap.keySet());
        System.out.println(hashMap.values());

//        for(String key:hashMap.keySet()){
//            System.out.println(hashMap.get(key));
//        }
        Iterator<String> it=hashMap.keySet().iterator();
        while (it.hasNext()){
            System.out.println(hashMap.get(it.next()));
        }
    }
}
